import { createRouter, createWebHashHistory } from 'vue-router'
import HomeView from '../views/HomeView.vue'
import Login from '../components/Login.vue'

const routes = [
  // 主页
  {
    path: '/',
    name: 'home',
    component: HomeView,
    meta: {
      requireAuth: true,
    },
  },
  // 登录页面
  {
    path: '/login',
    name: 'Login',
    component: Login,
  },
  // 商品页面
  {
    path: '/about',
    name: 'about',
    component: () => import('../views/AboutView.vue'),
    meta: {
      requireAuth: true,
    },
  },
  // 购物车页面
  {
    path: '/shoppingcard',
    name: 'shoppingcard',
    component: () => import('../views/ShoppingCardView.vue'),
  },
  // 商品详情页
  {
    path: '/detail',
    name: 'detail',
    component: () => import('../views/goodsdetail.vue'),
    meta: {
      requireAuth: true,
    },
  },
  //订单页面
  {
    path: '/orders',
    name: 'orders',
    component: () => import('../views/Orders.vue'),
    meta: {
      requireAuth: true,
    },
  },
]
const router = createRouter({
  history: createWebHashHistory(),
  routes,
})

export default router
